package com.aipsi.cws.common.exception;

/**
 * @author 大忽悠
 */
public class CustomException extends RuntimeException {
    private int code ;
    private String message;
    private static final int DEFAULT_ERROR_CODE=500;
    private static final CustomExceptionType DEFAULT_ERROR_TYPE=CustomExceptionType.INTERNAL_SERVER_ERROR;

    public CustomException(){
         this.code = DEFAULT_ERROR_TYPE.getCode();
         this.message=DEFAULT_ERROR_TYPE.getDesc();
    }

    public CustomException(String message) {
        this.code=DEFAULT_ERROR_CODE;
        this.message=message;
    }

    public CustomException(CustomExceptionType exceptionTypeEnum) {
        this.code = exceptionTypeEnum.getCode();
        this.message = exceptionTypeEnum.getDesc();
    }

    public CustomException(CustomExceptionType exceptionTypeEnum,
                           String message) {
        this.code = exceptionTypeEnum.getCode();
        this.message = message;
    }

    public int getCode() {
        return code;
    }

    @Override
    public String getMessage() {
        return message;
    }
}
